using HKB.Common;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web;
namespace HKB.Web
{
	public class Shop_Order
	{
		private Conn conn = null;
		private Pagination _pageHand = null;
		public Pagination pageHand
		{
			get
			{
				Pagination pageHand;
				if (this._pageHand == null)
				{
					this._pageHand = new Pagination();
					this._pageHand.SQL_CloseTablePre = false;
					this._pageHand.P_Object = Language.GetAdminMsg("Order/OrderName");
					pageHand = this._pageHand;
				}
				else
				{
					pageHand = this._pageHand;
				}
				return pageHand;
			}
		}
		public Shop_Order(Conn _conn)
		{
			this.conn = _conn;
		}
		public Shop_Order()
		{
			this.conn = Text.GetComponent<Conn>("conn", HttpContext.Current.CurrentHandler);
		}
		public DataTable GetAllOrders(int pageIndex, int maxperpage, string WhereStr, string OrderByStr)
		{
			return this.pageHand.GetDataTable("HLShop_Order", pageIndex, maxperpage, "OrderFormID", WhereStr, OrderByStr, this.conn, null);
		}
		public DataTable GetAllOrders(int pageIndex, int maxperpage, string WhereStr, string OrderByStr, params IDbDataParameter[] param)
		{
			return this.pageHand.GetDataTable("HLShop_Order", pageIndex, maxperpage, "OrderFormID", WhereStr, OrderByStr, this.conn, param);
		}
		public string GetPagePanel(string linkHead)
		{
			this.pageHand.P_LinkHead = linkHead;
			return this.pageHand.ShowPagePanel();
		}
		public DataTable GetOrderInfo(string OrderFormNum)
		{
			return this.conn.GetDataTable("select * from HLshop_Order where OrderFormNum='" + OrderFormNum + "'");
		}
		public DataTable GetOrderByOrderFormNum(string OrderFormNum)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@OrderFormNum", DbType.String, OrderFormNum);
			return this.conn.GetDataTable("select HLShop_Order.*, HLShop_OrderItem.*,HLShop_PayType.*  from HLShop_Order inner join HLShop_OrderItem on HLShop_Order.OrderFormID=HLShop_OrderItem.OrderFormID left join HLShop_PayType on HLShop_Order.SelectedPayType=HLShop_PayType.typeid   where (HLShop_Order.OrderFormNum=@OrderFormNum )  Order By HLShop_Order.OrderFormID Desc", new IDbDataParameter[]
			{
				dbDataParameter
			});
		}
		public DataTable GetAllByOrderFormNum(string OrderFormNum)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@OrderFormNum", DbType.String, OrderFormNum);
			return this.conn.GetDataTable("select HLShop_Order.*, HLShop_OrderItem.*,HLShop_PayType.*  from HLShop_Order inner join HLShop_OrderItem on HLShop_Order.OrderFormID=HLShop_OrderItem.OrderFormID left join HLShop_PayType on HLShop_Order.SelectedPayType=HLShop_PayType.typeid   where (HLShop_Order.OrderFormNum=@OrderFormNum )  Order By HLShop_Order.OrderFormID Desc ", new IDbDataParameter[]
			{
				dbDataParameter
			});
		}
		public DataTable GetTenPayByOrderFormNum(string OrderFormNum)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@OrderFormNum", DbType.String, OrderFormNum);
			return this.conn.GetDataTable("select HLShop_Order.*, HLShop_OrderItem.*,HLShop_PayType.*  from HLShop_Order inner join HLShop_OrderItem on HLShop_Order.OrderFormID=HLShop_OrderItem.OrderFormID left join HLShop_PayType on HLShop_Order.SelectedPayType=HLShop_PayType.typeid   where (HLShop_Order.OrderFormNum=@OrderFormNum )  Order By HLShop_Order.OrderFormID Desc  ", new IDbDataParameter[]
			{
				dbDataParameter
			});
		}
		public int GetStatus(string StatusName, int OrderID)
		{
			return this.conn.ExecuteCount(string.Concat(new object[]
			{
				"Select ",
				StatusName,
				" From [HLShop_Order] Where OrderFormID=",
				OrderID
			}));
		}
		public int GetStatus(string StatusName, string OrderFormNum)
		{
			return this.conn.ExecuteCount(string.Concat(new string[]
			{
				"Select ",
				StatusName,
				" From [HLShop_Order] Where OrderFormNum='",
				OrderFormNum,
				"'"
			}));
		}
		public DataTable GetOrderByOrderID(int OrderID)
		{
			return this.conn.GetDataTable("SELECT * From [HLShop_Order] Left Join [HLShop_OrderItem] On HLShop_OrderItem.OrderFormID=HLShop_Order.OrderFormID Where HLShop_Order.OrderFormID = " + OrderID);
		}
		public DataTable GetSaleOrder(string WhereStr, int SalerID, params IDbDataParameter[] param)
		{
			DataTable dataTable;
			if (WhereStr == string.Empty || WhereStr == null)
			{
				dataTable = this.conn.GetDataTable("Select * From [HLShop_Order] Where SalerID=" + SalerID + " Order By OrderFormID Desc");
			}
			else
			{
				if (param != null)
				{
					dataTable = this.conn.GetDataTable(string.Concat(new object[]
					{
						"Select * From [HLShop_Order] Where ",
						WhereStr,
						" and SalerID=",
						SalerID,
						" Order By OrderFormID Desc"
					}), param);
				}
				else
				{
					dataTable = this.conn.GetDataTable(string.Concat(new object[]
					{
						"Select * From [HLShop_Order] Where ",
						WhereStr,
						" and SalerID=",
						SalerID,
						" Order By OrderFormID Desc"
					}));
				}
			}
			return dataTable;
		}
		public DataTable GetBuyOrder(string TelPhone, string WhereStr, int UserID, params IDbDataParameter[] param)
		{
			DataTable dataTable;
			if (TelPhone == "")
			{
				if (WhereStr == string.Empty || WhereStr == null)
				{
                    dataTable = this.conn.GetDataTable("Select a.OrderFormID as OrderID, * From [HLShop_Order] as a, [HLShop_OrderItem] as b,dbo.HL_UserInfo c Where a.OrderFormID=b.OrderFormID AND a.SalerID=c.UserID and b.ID in(select max(ID) from HLShop_OrderItem group by OrderFormID) and a.UserID=" + UserID + "  Order By a.OrderFormID Desc");
				}
				else
				{
					if (param != null)
					{
						dataTable = this.conn.GetDataTable(string.Concat(new object[]
						{
							"Select a.OrderFormID as OrderID, * From [HLShop_Order] as a, [HLShop_OrderItem] as b,dbo.HL_UserInfo c  Where a.OrderFormID=b.OrderFormID AND a.SalerID=c.UserID and b.ID in(select max(ID) from HLShop_OrderItem group by OrderFormID) and ",
							WhereStr,
							" and a.UserID=",
							UserID,
							"  Order By a.OrderFormID Desc"
						}), param);
					}
					else
					{
						dataTable = this.conn.GetDataTable(string.Concat(new object[]
						{
							"Select a.OrderFormID as OrderID, * From [HLShop_Order] as a, [HLShop_OrderItem] as b,dbo.HL_UserInfo c  where a.OrderFormID=b.OrderFormID AND a.SalerID=c.UserID and b.ID in(select max(ID) from HLShop_OrderItem group by OrderFormID) and ",
							WhereStr,
							" and a.UserID=",
							UserID,
							"  Order By a.OrderFormID Desc"
						}));
					}
				}
			}
			else
			{
				if (param != null)
				{
					dataTable = this.conn.GetDataTable(string.Concat(new string[]
					{
						"Select a.OrderFormID as OrderID, * From [HLShop_Order] as a, [HLShop_OrderItem] as b,dbo.HL_UserInfo c  where a.OrderFormID=b.OrderFormID AND a.SalerID=c.UserID and b.ID in(select max(ID) from HLShop_OrderItem group by OrderFormID) and ",
						WhereStr,
						" and Mobile='",
						TelPhone,
						"'  Order By a.OrderFormID Desc"
					}), param);
				}
				else
				{
					dataTable = this.conn.GetDataTable(string.Concat(new string[]
					{
						"Select a.OrderFormID as OrderID, * From [HLShop_Order] as a, [HLShop_OrderItem] as b,dbo.HL_UserInfo c  where a.OrderFormID=b.OrderFormID AND a.SalerID=c.UserID and b.ID in(select max(ID) from HLShop_OrderItem group by OrderFormID) and ",
						WhereStr,
						" and Mobile='",
						TelPhone,
						"'  Order By a.OrderFormID Desc"
					}));
				}
			}
			return dataTable;
		}
		public bool DeleteOrder(string OrderIDArray)
		{
			bool result;
			if (OrderIDArray == string.Empty)
			{
				result = false;
			}
			else
			{
				this.conn.BeginTransaction();
				try
				{
					this.conn.ExecuteTransaction("Delete From [HLShop_Order] Where OrderFormID in(" + OrderIDArray + ")");
					this.conn.ExecuteTransaction("Delete From [HLShop_OrderItem] Where OrderFormID in(" + OrderIDArray + ")");
				}
				catch
				{
					this.conn.Rollback();
					result = false;
					return result;
				}
				this.conn.Commit();
				result = true;
			}
			return result;
		}
		public bool DeleteBuyerOrder(int UserID, string OrderIDArray)
		{
			bool result;
			if (OrderIDArray == string.Empty)
			{
				result = false;
			}
			else
			{
				this.conn.BeginTransaction();
				try
				{
					this.conn.ExecuteTransaction(string.Concat(new object[]
					{
						"Delete From [HLShop_Order] Where UserID=",
						UserID,
						" and OrderFormID in(",
						OrderIDArray,
						")"
					}));
					this.conn.ExecuteTransaction("Delete From [HLShop_OrderItem] Where OrderFormID in(" + OrderIDArray + ")");
				}
				catch
				{
					this.conn.Rollback();
					result = false;
					return result;
				}
				this.conn.Commit();
				result = true;
			}
			return result;
		}
		public bool DeleteSalerOrder(int SalerID, string OrderIDArray)
		{
			bool result;
			if (OrderIDArray == string.Empty)
			{
				result = false;
			}
			else
			{
				this.conn.BeginTransaction();
				try
				{
					this.conn.ExecuteTransaction(string.Concat(new object[]
					{
						"Delete From [HLShop_Order] Where SalerID=",
						SalerID,
						" and OrderFormID in(",
						OrderIDArray,
						")"
					}));
					this.conn.ExecuteTransaction("Delete From [HLShop_OrderItem] Where OrderFormID in(" + OrderIDArray + ")");
				}
				catch
				{
					this.conn.Rollback();
					result = false;
					return result;
				}
				this.conn.Commit();
				result = true;
			}
			return result;
		}
		public DataTable GetMaxAuctionPriceByProductID(int ProductID, int Cycle, bool NeedMoneyReceipt)
		{
			string text = "";
			if (NeedMoneyReceipt)
			{
				text = "and MoneyReceipt>0 ";
			}
			return this.conn.GetDataTable(string.Concat(new object[]
			{
				"SELECT TOP 1 * FROM HLShop_Order WHERE OrderFormID in(Select distinct(OrderFormID) From [HLShop_OrderItem] Where ProductID=",
				ProductID,
				") and Cycle=",
				Cycle,
				" and Status=0 and TradeType=2 ",
				text,
				" order by AuctionEndPrice Desc"
			}));
		}
		public bool AddAuctionOrderByAgent(decimal AuctionBuyMoney, int OrderFormID, int Status)
		{
			SqlParameter[] array = new SqlParameter[3];
			array[0] = new SqlParameter("@Price", DbType.Decimal);
			array[0].Value = AuctionBuyMoney;
			array[1] = new SqlParameter("@Status", DbType.Int32);
			array[1].Value = Status;
			array[2] = new SqlParameter("@OrderFormID", DbType.Int32);
			array[2].Value = OrderFormID;
			int num = this.conn.Execute("PR_AddOrderByAgent", array);
			return num == 1;
		}
		public bool AddAuctionOrderByAgent(int OrderFormID)
		{
			DataTable dataTable = this.conn.GetDataTable("Select AuctionEndPrice,MoneyGoods From [HLShop_Order] Where OrderFormID=" + OrderFormID);
			decimal auctionBuyMoney = (decimal)dataTable.Rows[0]["AuctionEndPrice"];
			return this.AddAuctionOrderByAgent(auctionBuyMoney, OrderFormID, 0);
		}
		public DataTable GetLastOrder(int ProductID, int UserID, int Cycle)
		{
			return this.conn.GetDataTable(string.Concat(new object[]
			{
				"Select top 1 MoneyReceipt,OrderFormNum From [HLShop_Order] Where OrderFormID in(Select (OrderFormID) From Where ProductID=",
				ProductID,
				") and UserID=",
				UserID,
				" and Cycle=",
				Cycle,
				" and TradeType=2"
			}));
		}
		public DataTable GetSalerAuctionOrderByProductID(int ProductID, int SalerID)
		{
			return this.conn.GetDataTable(string.Concat(new object[]
			{
				"Select * From [HLShop_Order] Where SalerID=",
				SalerID,
				" and TradeType=2 and OrderFormID in(Select distinct(OrderFormID) From HLShop_OrderItem Where ProductID=",
				ProductID,
				") Order By Cycle,InputTime Desc"
			}));
		}
		public DataTable GetBuyerAuctionOrderByProductID(int ProductID, int UserID)
		{
			return this.conn.GetDataTable(string.Concat(new object[]
			{
				"Select * From [HLShop_Order] Where UserID=",
				UserID,
				" and TradeType=2 and OrderFormID in(Select distinct(OrderFormID) From HLShop_OrderItem Where ProductID=",
				ProductID,
				") Order By Cycle,InputTime Desc"
			}));
		}
		public bool SetOrderLead(int OrderFormID, decimal CurrentPrice)
		{
			int num = (int)this.conn.GetScalar("Select top 1 ProductID from [HLShop_OrderItem] where OrderFormID=" + OrderFormID, new IDbDataParameter[0]);
			this.conn.BeginTransaction();
			bool result;
			try
			{
				this.conn.ExecuteTransaction(string.Concat(new object[]
				{
					"Update [HLShop_Product] Set CurrentPrice=",
					CurrentPrice,
					" Where ProductID=",
					num
				}));
				this.conn.ExecuteTransaction(string.Concat(new object[]
				{
					"Update [HLShop_Order] Set MoneyTotal=Deliver_TotalPrice+Invoice_TotalPrice+",
					CurrentPrice,
					", MoneyGoods=",
					CurrentPrice,
					", Status=1 Where OrderFormID=",
					OrderFormID
				}));
				this.conn.ExecuteTransaction(string.Concat(new object[]
				{
					"Update [HLShop_OrderItem] Set Price=",
					CurrentPrice,
					",totalPrice=((NeedInvoice*InvoiceRate/100)+1)*",
					CurrentPrice,
					" Where OrderFormID=",
					OrderFormID
				}));
			}
			catch
			{
				this.conn.Rollback();
				result = false;
				return result;
			}
			this.conn.Commit();
			result = true;
			return result;
		}
		public bool updateStatus(string OrderFormNum, string PayStatus, string DeliverStatus, string Status)
		{
			string text = "Update HLShop_Order Set ";
			string text2 = "";
			if (PayStatus != "")
			{
				if (text2 != "")
				{
					text2 = text2 + "," + text2;
				}
				text2 = " PayStatus=" + Convert.ToInt32(PayStatus);
			}
			if (Status != "")
			{
				if (text2 != "")
				{
					text2 = text2 + "," + text2;
				}
				text2 = " Status=" + Convert.ToInt32(Status);
			}
			if (DeliverStatus != "")
			{
				if (text2 != "")
				{
					text2 = text2 + "," + text2;
				}
				text2 = " DeliverStatus=" + Convert.ToInt32(DeliverStatus);
			}
			string text3 = text;
			text = string.Concat(new string[]
			{
				text3,
				text2,
				" Where OrderFormNum='",
				OrderFormNum,
				"'"
			});
			int num = this.conn.Execute(text);
			return num == 1;
		}
		public bool UpdateMoneyReceipt(int userID, decimal MoneyReceipt)
		{
			this.conn.BeginTransaction();
			bool result;
			try
			{
				this.conn.ExecuteTransaction(string.Concat(new object[]
				{
					"Update HL_Shop_Order set MoneyReceipt=",
					MoneyReceipt,
					"Where userID=",
					userID
				}));
			}
			catch
			{
				this.conn.Rollback();
				result = false;
				return result;
			}
			this.conn.Commit();
			result = true;
			return result;
		}
		public DataTable GetTeamBuyProductOrderByUserID(int UserID)
		{
			return this.conn.GetDataTable("Select O.*,I.* From [HLShop_Order] O Inner Join [HLShop_OrderItem] I On I.OrderFormID=O.OrderFormID Where O.TradeType=3 and O.UserID=" + UserID + " Order By O.OrderFormID Desc");
		}
		public DataTable GetSalerTeamBuyOrderByProductID(int ProductID, int Cycle, int Teameffect, int TeamLevel)
		{
			return this.conn.GetDataTable(string.Concat(new object[]
			{
				"Select * From [HLShop_Order] O Inner Join HLShop_OrderItem I On I.OrderFormID=O.OrderFormID Where O.Cycle=",
				Cycle,
				" and O.Teameffect=",
				Teameffect,
				" and O.TeamBuyLeavel=",
				TeamLevel,
				" and O.TradeType=3 and  I.ProductID=",
				ProductID,
				" Order By O.Cycle,O.InputTime Desc"
			}));
		}
		public DataTable GetAllTeamOrderForm(int ProductID)
		{
			return this.conn.GetDataTable("Select * From [HLShop_Order] O Inner Join HLShop_OrderItem I On I.OrderFormID=O.OrderFormID Where I.ProductID=" + ProductID + " Order By O.Cycle,O.InputTime Desc");
		}
		public int CountTeamBuyNum(int ProductID, int Cycle, int TeamBuyLeavel, bool NeedMoneyReceipt)
		{
			string text = "";
			if (NeedMoneyReceipt)
			{
				text = " and O.MoneyReceipt>0 ";
			}
			object scalar = this.conn.GetScalar(string.Concat(new object[]
			{
				"Select sum(I.Quantity) as Quantity From [HLShop_OrderItem] I Inner Join [HLShop_Order] O On O.OrderFormID=I.OrderFormID Inner Join [HLShop_Product] P On P.ProductID=I.ProductID Where P.ProductID=",
				ProductID,
				" and O.Cycle=",
				Cycle,
				" and O.TeamBuyLeavel<=",
				TeamBuyLeavel,
				text
			}), new IDbDataParameter[0]);
			int result;
			if (scalar != null && scalar != DBNull.Value)
			{
				result = Convert.ToInt32(scalar);
			}
			else
			{
				result = 0;
			}
			return result;
		}
		public DataTable GetProductSaleOrderByProductID(int ProductID, int PageIndex, int Counts)
		{
			if (PageIndex <= 0)
			{
				PageIndex = 1;
			}
			string str = "HLShop_OrderItem.ProductID=" + ProductID.ToString();
			DataTable dataTable;
			if (Counts == 1)
			{
				dataTable = this.conn.GetDataTable("select count(*) as Total From HLShop_Order Where OrderFormID in(Select DISTINCT(OrderFormID) From HLShop_OrderItem Where " + str + ") ");
			}
			else
			{
				string sQL_Fields = "BuyerName,UserID,MoneyGoods,UpdateTime,Status,PayStatus,shopid";
				string orderBy = "UpdateTime Desc";
				dataTable = new Pagination
				{
					SQL_Fields = sQL_Fields,
					SQL_CloseTablePre = false
				}.GetDataTable("HLShop_Order", PageIndex, Counts, "OrderFormID", "Where OrderFormID in(Select DISTINCT(OrderFormID) From HLShop_OrderItem Where " + str + ")", orderBy, this.conn, null);
			}
			return dataTable;
		}
		public DataTable GetProductSaleOrderByProductID(int ProductID)
		{
			return this.conn.GetDataTable("SELECT BuyerName,UserID,MoneyGoods,UpdateTime,Status,PayStatus,shopid,Quantity,price From HLShop_Order,HLShop_OrderItem WHERE HLShop_Order.OrderFormID = HLShop_OrderItem.OrderFormID AND ProductID = " + ProductID);
		}
		public DataTable getproductSaleCount(string WhereStr, int SalerID, params IDbDataParameter[] param)
		{
			DataTable result = new DataTable();
			string str = " ROW_NUMBER() OVER (order by Sum(Quantity) desc) as row,Sum(TotalPrice) as Total,Sum(Quantity) as TotalNum,SUM(PresentExpTotal) as PresentExpTotal,ProductName,ProductID ";
			string text = "HLShop_Order.OrderFormID=HLShop_OrderItem.OrderFormID Group by ProductName,ProductID Order by TotalNum desc";
			string text2 = "Select " + str + " From [HLShop_Order],[HLShop_OrderItem] Where ";
			if (SalerID > 0)
			{
				if (WhereStr == string.Empty || WhereStr == null)
				{
					result = this.conn.GetDataTable(string.Concat(new object[]
					{
						" SalerID=",
						SalerID,
						" and ",
						text
					}));
				}
				else
				{
					if (param != null)
					{
						result = this.conn.GetDataTable(string.Concat(new object[]
						{
							text2,
							WhereStr,
							" and SalerID=",
							SalerID,
							" and ",
							text
						}), param);
					}
					else
					{
						result = this.conn.GetDataTable(string.Concat(new object[]
						{
							text2,
							WhereStr,
							" and SalerID=",
							SalerID,
							" and ",
							text
						}));
					}
				}
			}
			else
			{
				result = this.conn.GetDataTable(text2 + text);
			}
			return result;
		}
		private string getproductSaleCountSql(string WhereStr, int SalerID)
		{
			string str = " ROW_NUMBER() OVER (order by Sum(Quantity) desc) as row,Sum(TotalPrice) as Total,Sum(Quantity) as TotalNum,SUM(PresentExpTotal) as PresentExpTotal,ProductName,ProductID ";
			string str2 = " Group by ProductName,ProductID";
			string text = "Select " + str + " From [HLShop_Order],[HLShop_OrderItem] Where HLShop_Order.OrderFormID=HLShop_OrderItem.OrderFormID";
			if (SalerID > 0)
			{
				object obj = text;
				text = string.Concat(new object[]
				{
					obj,
					" and SalerID=",
					SalerID,
					" "
				});
			}
			return text + WhereStr + str2;
		}
		public int getproductSaleCountRecordCount(string WhereStr, int SalerID, params IDbDataParameter[] param)
		{
			int result = 0;
			string text = this.getproductSaleCountSql(WhereStr, SalerID);
			DataTable dataTable;
			if (param != null)
			{
				dataTable = this.conn.GetDataTable(text, param);
			}
			else
			{
				dataTable = this.conn.GetDataTable(text);
			}
			if (dataTable.Rows.Count > 0)
			{
				result = dataTable.Rows.Count;
			}
			return result;
		}
		public DataTable getproductSaleCountPage(string WhereStr, int SalerID, int startIndex, int endIndex, params IDbDataParameter[] param)
		{
			string text = this.getproductSaleCountSql(WhereStr, SalerID);
			string text2 = string.Concat(new object[]
			{
				"SELECT * FROM ( ",
				text,
				" ) as TT WHERE TT.row between ",
				startIndex,
				" and ",
				endIndex
			});
			DataTable dataTable;
			if (param != null)
			{
				dataTable = this.conn.GetDataTable(text2, param);
			}
			else
			{
				dataTable = this.conn.GetDataTable(text2);
			}
			return dataTable;
		}
		private string GetSaleOrderSql(string WhereStr, int SalerID)
		{
			string str = "Select  ROW_NUMBER() OVER (Order By OrderFormID Desc) as row,* From [HLShop_Order] Where 1=1 ";
			string str2 = "";
			if (SalerID > 0)
			{
				str2 = " and SalerID=" + SalerID + " ";
			}
			return str + str2 + WhereStr;
		}
		public int GetSaleOrderRecordCount(string WhereStr, int SalerID, params IDbDataParameter[] param)
		{
			int result = 0;
			string saleOrderSql = this.GetSaleOrderSql(WhereStr, SalerID);
			DataTable dataTable;
			if (param != null)
			{
				dataTable = this.conn.GetDataTable(saleOrderSql, param);
			}
			else
			{
				dataTable = this.conn.GetDataTable(saleOrderSql);
			}
			if (dataTable.Rows.Count > 0)
			{
				result = dataTable.Rows.Count;
			}
			return result;
		}
		public DataTable GetSaleOrderPage(string WhereStr, int SalerID, int startIndex, int endIndex, params IDbDataParameter[] param)
		{
			string saleOrderSql = this.GetSaleOrderSql(WhereStr, SalerID);
			string text = string.Concat(new object[]
			{
				"SELECT * FROM ( ",
				saleOrderSql,
				" ) as TT WHERE TT.row between ",
				startIndex,
				" and ",
				endIndex
			});
			DataTable dataTable;
			if (param != null)
			{
				dataTable = this.conn.GetDataTable(text, param);
			}
			else
			{
				dataTable = this.conn.GetDataTable(text);
			}
			return dataTable;
		}
		public DataTable GetOrderAreadyByOrderID(int OrderFormID)
		{
			string text = "UserID,BuyerName,SalerID,SalerName,MoneyGoods,Deliver_TotalPrice,Invoice_TotalPrice,MoneyTotal,MoneyReceipt,";
			string text2 = "(select SUM(MoneyTrue) as MoneyTrue from HLShop_PayInfo where LOWER(Status)='pay' and OrderFormNum=o.OrderFormNum group by OrderFormNum) as alMoneyReceipt,";
			string text3 = "(select top 1 PayTime from HLShop_PayInfo where LOWER(Status)='pay' and OrderFormNum=o.OrderFormNum order by PayTime desc)as PayTime";
			string sql = string.Concat(new object[]
			{
				"select ",
				text,
				text2,
				text3,
				" from HLShop_Order as o where  o.OrderFormID in (",
				OrderFormID,
				")"
			});
			return this.conn.GetDataTable(sql);
		}
	}
}
